extends Item
var ctrl = globalData.infoDs["g_AneHek"]
func init():
	type = config.EQUITYPE_EQUI
	attInit()
	att.maxHp = 100
	att.def = 100
	att.mgiDef = 100
	att.atkRan = 1
	name = "[color=yellow]妖之笛[/color]"
	info = "[color=red]每秒有22%概率为攻击范围内的敌人附加1层<离间>[cd:5秒]\n[/color][color=#666666]诗人/吟游诗人专属：概率改为33%[未解锁][/color]"

var cnt = 0
var flag = 0
var rd = 22

func _connect():
	if masCha.id.find("cTDP_6") != -1:
		rd = 33
		info = info.replace("[color=#666666]诗人/吟游诗人专属：概率改为33%[未解锁][/color]","[color=blue]诗人/吟游诗人专属：概率改为33%[已解锁][/color]")
	else:
		rd = 22
		info = "[color=red]每秒有33%概率为攻击范围内的敌人附加1层<离间>[cd:5秒]\n[/color][color=#666666]诗人/吟游诗人专属：概率改为33%[未解锁][/color]"
	sys.main.connect("onBattleStart",self,"run")

func run():
	cnt = 0
	flag = 0

func _upS():
	._upS()
	if masCha.isDeath:return
	if !flag && sys.rndPer(rd):
		flag = 1
		var chas = masCha.getAllChas(1)
		for i in chas:
			if inrange(i.cell,masCha.cell,masCha.att.atkRan):
				i.addBuff(ctrl.b_lijian.new(1))
	#if sys.test:
	#	print(cnt)
	if flag:
		cnt += 1
		if cnt % 5 == 0:
			flag = 0
			cnt = 0

func inrange(a,b,c):
	var x = abs(a.x - b.x)
	var y = abs(a.y - b.y)
	return x*x + y*y <= c*c